package simbot.example.config.pool;

import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;

import java.util.List;

/**
 * 定时任务配置
 *
 * @author minmin
 * @since 2021 /07/02 22:14
 */
@Configuration
@ConfigurationProperties("animation.push")
@Getter
@Setter
public class ScheduleAnimationThreadPoolConfig {
    private List<String> groups;

    /**
     * Animation thread pool task scheduler thread pool task scheduler.
     *
     * @return the thread pool task scheduler
     */
    @Bean
    public ThreadPoolTaskScheduler animationThreadPoolTaskScheduler() {
        ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
        threadPoolTaskScheduler.setPoolSize(groups.size());
        threadPoolTaskScheduler.setThreadNamePrefix("schedule-animation-push");
        return threadPoolTaskScheduler;
    }
}
